package com.yang.doctorrecruitment.action;

import com.alibaba.fastjson.JSONObject;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.yang.doctorrecruitment.dao.UserResumeDAO;
import com.yang.doctorrecruitment.dto.AppendInformation;
import com.yang.doctorrecruitment.utils.NullChange;
import org.apache.struts2.ServletActionContext;

import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.util.Map;

public class AppendInformationAction extends ActionSupport {
    public AppendInformation appendinformation;
    public String AppendInformation(){
        //File Photo=appendinformation.getPhoto();
        String SelfAssessment= NullChange.NullChange(appendinformation.getSelfAssessment());
        JSONObject json=new JSONObject();
        json.put("SelfAssessment",SelfAssessment);

        String jsonString =json.toJSONString();
        ActionContext ac=ActionContext.getContext();
        Map session=ac.getSession();
        String UserID= (String) session.get("UserID");

        HttpServletRequest request= (HttpServletRequest) ac.get(ServletActionContext.HTTP_REQUEST);
        boolean res= UserResumeDAO.updataAppend(jsonString,UserID);
        if(res){
            request.setAttribute("tipMessage",1);
            return SUCCESS;
        }else{
            request.setAttribute("tipMessage",2);
            return ERROR;
        }
    }
    public AppendInformation getAppendinformation() {
        return appendinformation;
    }

    public void setAppendinformation(AppendInformation appendinformation) {
        this.appendinformation = appendinformation;
    }
}
